package Server.Poker.DGT;

import java.util.Random;

public class Constants {

	public final static int MAX_TABLE_SIZE = 100;

	public final static int MAX_USER_SIZE = 2000;

	static long getTickCount() {
		return (int) System.currentTimeMillis();
	}

	public static void memset(int[] vecAllUser, int i) {
		if (vecAllUser != null) {
			for (int j = 0; j < vecAllUser.length; j++) {
				vecAllUser[j] = i;
			}
		}
	}

	public static int getTime() {
		return (int) System.currentTimeMillis();
	}

	public static int atoi(String strint) {
		int i = 0;
		try {
			i = Integer.parseInt(strint);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return i;
	}

	public final static int PktID_DDZ_Base = 1000;

	public final static int PktID_DDZ_AutoMatch = 1001;// �ͻ�����������䣨ֱ�ӽ�����,�����ﶯ̬�������ӳ���)

	public final static int PktID_DDZ_UserSit = 1002;// �ͻ�����������䣨ֱ�ӽ�����,�����ﶯ̬�������ӳ���)
	public final static int PktID_DDZ_UserSitResult = 1003;// �ͻ���������������ɹ��ͷ���������Ϣ���������GAMEDATA���أ���������Ǹ����û��ѳɹ����룬���������������ʱ������GAMEDATA��table��Ϣ���غ��ٽ��д���
	public final static int PktID_DDZ_UserStandUp = 1004;
	public final static int PktID_DDZ_UserStandUpResult = 1005;

	public final static int PktID_DDZ_ChangeTable = 1100;
	public final static int PktID_DDZ_TableData = 1101;// �ͻ�����������������ݣ����з��
	public final static int PktID_DDZ_TableDataResult = PktID_DDZ_TableData;// ����������ͻ��˷�������

	public final static int PktID_Base = 0;

	public final static int PktID_Login = 10;
	public final static int PktID_LoginResult = 11;

	public final static int PktID_UserEnterRoom = 14;
	public final static int PktID_UserEnterRoomResult = 15;
	public final static int PktID_UserLeaveRoom = 16;
	public final static int PktID_UserLeaveRoomResult = 17;

	public final static int PktID_Login2 = 100;
	public final static int PktID_Register3 = 101;
	public final static int PktID_RegisterResult = 102;
	public final static int PktID_Login3 = 103;

	
	public static final int INIT_TOTAL = 0; // �ƾ�ȫ�����
	public static final int INIT_NEWROUND = 2; // Ϊ����һ�ѳ�ʼ��һЩ����
	public static final int INIT_FIRST_ROUND = 1; // �ƾ�ȫ�����
	
	public static int GAME_END_DISMISS = 4;
	
	
	public static final int sizeof(long[] m_LookOnUserID) {
		return m_LookOnUserID.length;
	}
	
	public static void memset(SSeatInfo[] m_seatInfo, int by2, int sizeof) {
		for (int i = 0; i < m_seatInfo.length; i++) {
			m_seatInfo[i] = new SSeatInfo();
		}
	}
	
	public static void memset(long[] by, int by2, int length) {
		for (int i = 0; i < length; i++) {
			by[i] = (long) by2;
		}

	}

	public static int random(int i, int j) {
		return rd.nextInt(j - i) + i;
	}

	public static int time(Object object) {
		return (int)System.currentTimeMillis();
	}

	public final static int DDZ_PLAYER = 5; // ��Ϸ����
	public final static int MAX_CHAIR = DDZ_PLAYER;
	public final static int USER_INDEX = 1; // ��ҵ�����
	public final static int TABLE_ID = 0; // ��������

	// ��Ϸ״̬
	public final static int GS_FREE = 0; // ����״̬
	public final static int GS_PLAYING = 100; // ��Ϸ״̬

	// ��Ϸ״̬
	public final static int GS_WK_FREE = GS_FREE; // �ȴ���ʼ
	public final static int GS_WK_SCORE = GS_PLAYING; // �з�״̬
	public final static int GS_WK_PLAYING = GS_PLAYING + 1; // ��Ϸ����

	// ��Ϸ����
	public final static int DOUBLE_SCORE = 0x04; // ����

	public final static int CALL_SCORE_ONE = 0x11; // ��ׯ
	public final static int CALL_SCORE_TWO = 0x12; // �з�
	public final static int CALL_SCORE_THREE = 0x13; // �д��
	//////////////////////////////////////////////////////////////////////////
	// ����������ṹ

	public final static int SUB_S_SEND_CARD = 100; // ��������
	public final static int SUB_S_CHOICE_LOOK = 106; // ��ׯ����
	public final static int SUB_S_LAND_SCORE = 101; // �з�����
	public final static int SUB_S_GAME_START = 102; // ��Ϸ��ʼ
	public final static int SUB_S_OUT_CARD = 103; // �û�����
	public final static int SUB_S_PASS_CARD = 104; // ��������
	public final static int SUB_S_GAME_END = 105; // ��Ϸ����
	public final static int SUB_S_JIAOGOUTUI = 107; // �й���
	public final static int SUB_S_PLAYERGOUTUI = 108; // �й���
	public final static int SUB_S_GAME_DISMISS = 255; // ��Ϸ����

	public final static int SUB_S_GAME_SCENE = 200; // ��Ϸ����
	
	
	
	public final static int  INVALID_WORD		=		((0xFF))		;			//��Ч��ֵ
	
	public final static int  INVALID_CHAIR		=		INVALID_WORD;						//��Ч����

	public static int sizeof(int[] m_bCallScoreTimes) {
		return m_bCallScoreTimes.length;
	}

	public static void memset(int[] m_bScoreTimes, int i, int sizeof) {
		for (int j = 0; j < m_bScoreTimes.length; j++) {
			 m_bScoreTimes[j] = i;
		}
	}

	public static int sizeof(boolean[] m_bUserTrustee) {
		return m_bUserTrustee.length;
	}
	
	
	
	//�����궨��
	public final static int  MDM_GR_USER		=			2		;							//�û���Ϣ

	public final static int  SUB_GR_USER_SIT_REQ	=		1;									//��������
	public final static int  SUB_GR_USER_LOOKON_REQ	=	2	;								//�Թ�����
	public final static int  SUB_GR_USER_STANDUP_REQ	=	3	;								//��������
	public final static int  SUB_GR_USER_LEFT_GAME_REQ=	4	;								//�뿪��Ϸ

	public final static int  SUB_GR_TABLE_INFO			=201		;							//������Ϣ
	public final static int  SUB_GR_USER_ENTER_TABLE		=202;
	public final static int  SUB_GR_USER_LEAVE_TABLE	=	203;
	public final static int  SUB_GR_TABLE_STATUS		=	204		;							//����״̬

	public final static int  SUB_GR_USER_INFO		=	300		;							//�û���Ϣ
	public final static int  SUB_GR_USER_STATUS		=	301		;							//�û�״̬
	public final static int  SUB_GR_USER_SCORE		=	302		;							//�û�����
	public final static int  SUB_GR_SIT_FAILED	=		303	;								//����ʧ��

	public final static int  SUB_GR_USER_CHAT		=	1000	;							//������Ϣ
	public final static int  SUB_GR_USER_WISPER		=	1001	;							//˽����Ϣ
	public final static int  SUB_GR_USER_RULE			=1002		;						//�û�����

	public final static int  SUB_GR_USER_INVITE		=	305		;							//������Ϣ
	public final static int  SUB_GR_USER_INVITE_REQ	=	306	;								//��������
	public final static int  SUB_GR_KILL_USER		=	307			;						//�߳��û�
	
	
	
	
	
//////////////////////////////////////////////////////////////////////////
//����ʱ��
	public final static int   IDI_ANDROID_ITEM_SINK		=	500		;							//��ʼ��ʶ
//����ά��
	//public final static int   CountArray(Array) (sizeof(Array)/sizeof(Array[0]))
//////////////////////////////////////////////////////////////////////////
//��Ч��ֵ
	public final static int   INVALID_BYTE			=	((0xFF))			;			//��Ч��ֵ
	//public final static int   INVALID_WORD		=		((0xFFFF))			;		//��Ч��ֵ
	public final static int   INVALID_DWORD		=		((0xFFFFFFFF))		;		//��Ч��ֵ
//��Ч��ֵ
	//public final static int   INVALID_CHAIR		=		INVALID_WORD		;				//��Ч����

//////////////////////////////////////////////////////////////////////////
//�û�״̬����
	public final static int   US_NULL				=			0x00			;					//û��״̬
	public final static int   US_FREE			=				0x01			;					//վ��״̬
	public final static int   US_SIT				=			0x02				;				//����״̬
	public final static int   US_READY		=				0x03		;						//ͬ��״̬
	public final static int   US_LOOKON		=				0x04		;						//�Թ�״̬
	public final static int   US_PLAY				=			0x05			;					//��Ϸ״̬
	public final static int   US_OFFLINE			=			0x06				;				//����״̬
//���Ⱥ궨��
	public final static int   USERNAME_LEN			=			32	;								//���ֳ���
	public final static int   PASS_LEN				=		33			;						//���볤��
	public final static int   EMAIL_LEN			=			32				;					//���䳤��
	public final static int   GROUP_LEN		=				32			;						//���ų���
	public final static int   COMPUTER_ID_LEN			=		33	;								//��������
	public final static int   UNDER_WRITE_LEN			=		32	;								//����ǩ��
	public final static int   SERVER_LEN				=		32			;						//���䳤��

//
	public final static int   GER_NORMAL				=		0x00			;					//�������
	public final static int   GER_DISMISS		=				0x01				;				//��Ϸ��ɢ
	public final static int   GER_USER_LEFT		=			0x02				;				//�û��뿪

//��Ϸ����
	public final static int   GAME_GENRE_SCORE	=			0x0001			;					//��ֵ����
	public final static int   GAME_GENRE_GOLD		=			0x0002			;					//�������
	public final static int   GAME_GENRE_MATCH		=		0x0004			;					//��������
	public final static int   GAME_GENRE_EDUCATE	=			0x0008		;						//ѵ������
	public final static int   GAME_GENRE_SINGLE		=		0x00010		;						//��������

//////////////////////////////////////////////////////////////////////////

//��������
	public final static int   ST_ORDER			=		0			;						//��С����
	public final static int   ST_COUNT			=		1			;						//��Ŀ����

//��Ŀ����

	public final static int   MAX_COUNT		=			38			;						//�����Ŀ
	public final static int   FULL_COUNT		=			162		;							//ȫ����Ŀ
	public final static int   GOOD_CARD_COUTN		=		38		;							//������Ŀ
	public final static int   BACK_COUNT				=	7				;					//������Ŀ
	public final static int   NORMAL_COUNT		=		31		;							//������Ŀ

//////////////////////////////////////////////////////////////////////////

//��ֵ����
	public final static int  	MASK_COLOR			=		0xF0		;						//��ɫ����
	public final static int  	MASK_VALUE		=			0x0F		;						//��ֵ����

//�˿�����
	public final static int   CT_ERROR			=		0				;					//��������
	public final static int   CT_SINGLE			=		1				;					//��������
	public final static int   CT_DOUBLE		=			2				;					//��������
	public final static int   CT_THREE		=			3				;					//��������
	public final static int   CT_SINGLE_LINE		=		4			;						//��������
	public final static int   CT_DOUBLE_LINE		=		5			;						//��������
	public final static int   CT_THREE_LINE			=	6						;			//��������
	public final static int   CT_THREE_LINE_TAKE_ONE	=	7		;							//����һ��
	public final static int   CT_THREE_LINE_TAKE_TWO		=8		;							//����һ��
	public final static int   CT_FOUR_LINE_TAKE_ONE	=	9			;						//�Ĵ�����
	public final static int   CT_FOUR_LINE_TAKE_TWO	=	10		;							//�Ĵ�����
	public final static int   CT_BOMB_CARD			=	11				;					//ը������
	public final static int   CT_MISSILE_CARD		=		12		;							//�������
	
	public final static int   CT_THREE_LINE_TAKE_TWO_ONE		=		13		;							//��������

//���ض���
	public final static int   MAX_PELS			=		25		;							//��С����
	public final static int   LESS_PELS		=			10		;							//��С����
	public final static int   DEFAULT_PELS	=			20			;						//Ĭ������

	

	public static String sprintf_Array(int[] by, int count) {
		if (count < 1)
		{
			return "";
		}
		String acBuffer = "";

		String out_str;
		acBuffer += String.format("[%d", by[0]);
		out_str = acBuffer;
		for (int i = 1; i < count; i++)
		{
			acBuffer = String.format(i == (count - 1) ? ",%d]" : ",%d", by[i]);
			out_str = out_str + acBuffer;
		}
		return out_str;
	}

	public static String sprintf_Array(boolean[] bUserTrustee, int ddzPlayer) {
		int[] by = new int[ddzPlayer];
		for (int i = 0; i < bUserTrustee.length; i++) {
			by[i] = bUserTrustee[i]?1:0;
		}
		return sprintf_Array(by, ddzPlayer);
	}
	
	
//////////////////////////////////////////////////////////////////////////
//�ͻ�������ṹ

public final static int    SUB_C_LAND_SCORE		=	1		;							//�û��з�
public final static int    SUB_C_OUT_CART		=		2		;							//�û�����
public final static int    SUB_C_PASS_CARD	=			3		;							//��������
public final static int    SUB_C_TRUSTEE			=	4			;						//�й���Ϣ

public final static int    SUB_C_USER_READY		=	10		;							//׼�� add by ele

public static void CopyMemory(int[] bScoreInfo, int[] m_bScoreInfo) {
	for (int i = 0; i < m_bScoreInfo.length; i++) {
		bScoreInfo[i]= m_bScoreInfo[i];
	}
}

public static void CopyMemory(boolean[] bUserTrustee, boolean[] m_bUserTrustee) {
	for (int i = 0; i < m_bUserTrustee.length; i++) {
		bUserTrustee[i] = m_bUserTrustee[i];
	}
	
}
public static void memset(boolean[] m_bUserTrustee, int b) {
	memset(m_bUserTrustee,b==1?true:false);
}
public static void memset(boolean[] m_bUserTrustee, boolean b) {
	for (int i = 0; i < m_bUserTrustee.length; i++) {
		 m_bUserTrustee[i] = b;
	}
}

public static void memset(int[][] m_bHandCardData, int i) {
	for (int j = 0; j < m_bHandCardData.length; j++) {
		int[] is = m_bHandCardData[j];
		for (int k = 0; k < is.length; k++) {
			is[k] = i;
		}
	}
	
}
public static Random rd = new Random();
public static String getRandName(Object random) {
	String	vecNames[] = {"������","Ԫ��","��һһ","Ѫ��","����","����ײ����","ëԲԲ","����","������","��Ѫ","���ζ�","������"} ;
	int rdInt = rd.nextInt(vecNames.length);
	return vecNames[rdInt % vecNames.length];
}

public static int abs(int base) {
	return Math.abs(base);
}

public static int rand() {
	return Math.abs(rd.nextInt());
}

public final static int    	GOOD_CARD_PERCENT	=			20		;							//���Ƹ���

public final static int    	MAX_CALL_TIMES			=		2			;						//��������

public static void ZeroMemory(int[] m_bScoreInfo) {
	for (int i = 0; i < m_bScoreInfo.length; i++) {
		m_bScoreInfo[i] = 0;
	}
}


public static void CopyMemory(int[] x, int[] y, int l) {
	for (int i = 0; i < l && i < x.length && i < y.length; i++) {
		x[i] = y[i];
	}
}

public static void CopyMemory(int[] x, int no, int l) {
	for (int i = 0; i < x.length; i++) {
		x[i] = no;
	}
}




public static int __min(int x, int y) {
	return Math.min(x, y);
}

public static int __max(int x, int y) {
	return Math.max(x, y);
}

public static void CopyMemory(int[] cbLandScoreCardData, int normalCount, int[] bBackCardData, int backCount) {
	for (int i = 0; i < bBackCardData.length && i < backCount; i++) {
		cbLandScoreCardData[normalCount + i] = bBackCardData[i];
	}
}



//public final static int	enScoreKind_Win = 1;				//ʤ
//public final static int	enScoreKind_Lost = 2;					//��
//public final static int	enScoreKind_Draw = 3;					//��
//public final static int enScoreKind_Flee = 4;					//��

	
//����ʱ��
public final static int TIME_LESS			=		1				;					//����ʱ��2
public final static int TIME_DISPATCH	=			5		;							//����ʱ��5

//��Ϸʱ��
public final static int TIME_CALL_SCORE			=	1		;							//�з�ʱ��2

//��Ϸʱ��
public final static int IDI_OUT_CARD		=		(IDI_ANDROID_ITEM_SINK+0)		;	//����ʱ��
public final static int IDI_START_GAME		=		(IDI_ANDROID_ITEM_SINK+1);			//��ʼʱ��
public final static int IDI_CALL_SCORE			=	(IDI_ANDROID_ITEM_SINK+2)		;	//�з�ʱ��
public final static int IDI_CALL_BANKER		=		(IDI_ANDROID_ITEM_SINK+3)	;		//ץ��ʱ��

//��Ϸ��ʱ��
public final static int IDI_MOST_CARD		=			201		;						//���ʱ��
public final static int IDI_LAND_SCORE		=			203			;					//�зֶ�ʱ��
public final static int IDI_DISPATCH_CARD		=		204		;						//���ƶ�ʱ��
public final static int IDI_LOOK_CATCH			=		205		;						//��ׯ��ʱ��

public final static int TIME_OUT_CARD				=	3			;					//���ƶ�ʱ��
public final static int TIME_AI_OUT_CARD	=			2		;						//���ƶ�ʱ��
public final static int TIME_START_GAME			=		3		;						//��ʼ��ʱ��

public final static float TIME_DISPATCH_CARD	=			0.12f	;						//���ƶ�ʱ��

public static int CountArray(int[] bBackCard) {
	return bBackCard.length;
}

public static void CopyMemory(int[] m_cbHandCardData, int[][] bCardData, int m_cbHandCardCount) {
	// TODO �Զ����ɵķ������
	
}
	
public final static int MAX_TYPE_COUNT = 254;

public static void ZeroMemory(boolean[] m_bCallScore) {
	for (int i = 0; i < m_bCallScore.length; i++) {
		m_bCallScore[i] = false;
	}
}

public static void memcpy(int[] cbLineCardData, int cbLineCardCount, int[] cbSingleLineCard, int cbSingleLineCount) {
	// TODO �Զ����ɵķ������
	for (int i = 0; i < cbSingleLineCount; i++) {
		cbLineCardData[cbLineCardCount+i] = cbSingleLineCard[i];
	}
}


public static void CopyMemory(int[] cbResultCard,int num1, int[] cbHandCardData, int num2, int backCount) {
	for (int i = 0; i < backCount; i++) {
		cbResultCard[num1+i] = cbHandCardData[num2+i];
	}
}
public static void CopyMemory(int[] cbResultCard, int[] cbHandCardData, int i, int backCount) {
	CopyMemory(cbResultCard,0,cbHandCardData,i,backCount);
}

public static int time() {
	return (int)System.currentTimeMillis();
}

public static int[] ArrayAdd(int[] cbTurnCardData, int youyiK) {
	int news[] = new int[cbTurnCardData.length - youyiK];
	for (int i = 0; i < news.length; i++) {
		news[i] = cbTurnCardData[i+youyiK];
	}
	return news;
}

public static int rand(int i, int j, int factor) {
	return rd.nextInt(j - i) + i;
}


}
